package wzt.com.JiaBangMang.netManagementServer;

import wzt.com.JiaBangMang.Server.DBControl.IDBManager;
import wzt.com.JiaBangMang.Server.DBControl.MySqlDBManager;
import wzt.com.JiaBangMang.netProtocol.NetCmdObject.AbstractNetCmdExecute;
import wzt.com.JiaBangMang.netProtocol.NetCmdObject.INetCmdExecuteResult;

public class MGServerCmdExecute extends AbstractNetCmdExecute {

	@Override
	public IDBManager getDBManager() {
		if(this.dbManager == null)
			this.dbManager = new MySqlDBManager();
		return this.dbManager;
	}

	@Override
	public void setDBManager(IDBManager db) {
		this.dbManager = db;
	}


	@Override
	public INetCmdExecuteResult getResult(String cmd, boolean succeed,
			String retInfo, String error) {
		INetCmdExecuteResult rs = new ReturnInfo(cmd,succeed,retInfo,error);
		return rs;
	}


}

class ReturnInfo implements INetCmdExecuteResult{
	private boolean success = false;
	private String returnInfo = "";
	private String failInfo = "";
	private String cmd = null;
	public ReturnInfo(String cmd,boolean success,String returnInfo ,String error)
	{
		this.cmd = cmd;
		this.success = success;
		this.returnInfo = returnInfo;
		this.failInfo = error;
	}
	@Override
	public boolean getIsSucceed() {
		return success;
	}
	@Override
	public String getError() {
		return failInfo;
	}
	@Override
	public String getResult() {
		return returnInfo;
	}
	
	@Override
	public String getCmd() {
		return cmd;
	}
}